package com.define.ssh.action.admin;

import java.util.Date;
import javax.annotation.Resource;
import com.define.ssh.model.SysVariables;
import com.define.ssh.service.SysVariablesService;

/**
 * 系统参数操作
 * 
 * @author hcy
 * 
 */
public class SysVariableAction extends BaseAdminAction {
	private static final long serialVersionUID = 5L;

	/** 页面传递参数过来 */
	protected int pageSize;
	protected int pageNum;

	@Resource(name = "sysVariablesServiceImpl")
	private SysVariablesService sysVariablesService;

	private SysVariables sysVariables;

	/**
	 * 列表页
	 * 
	 * @return
	 * @throws Exception
	 */
	public String list() {
		pager = sysVariablesService.findPager(pager);
		return LIST;
	}

	// 删除
	public String delete() {
		for (final Long id : ids) {
			final SysVariables ss = sysVariablesService.load(id);
			// 删除系统参数
			sysVariablesService.delete(ss);
		}
		return ajax(Status.success, "删除成功!");
	}

	// 添加
	public String add() {
		return INPUT;
	}

	// 编辑
	public String edit() {
		sysVariables = sysVariablesService.load(id);
		return INPUT;
	}

	// 保存
	public String save() {
		sysVariables.setCreateDate(new Date());
		sysVariables.setModifyDate(new Date());
		sysVariablesService.save(sysVariables);
		return ajax(Status.success, "添加系统参数成功");
	}

	// 更新
	public String update() {
		final SysVariables sysVariables1 = sysVariablesService.load(id);
		sysVariables1.setModifyDate(new Date());
		sysVariables1.setSysName(sysVariables.getSysName());
		sysVariables1.setSysValue(sysVariables.getSysValue());
		sysVariables1.setSysCode(sysVariables.getSysCode());
		sysVariables1.setIsUpdate(sysVariables.getIsUpdate());
		sysVariablesService.update(sysVariables1);
		return ajax(Status.success, "修改系统参数成功");
	}

	public SysVariablesService getSysVariablesService() {
		return sysVariablesService;
	}

	public void setSysVariablesService(SysVariablesService sysVariablesService) {
		this.sysVariablesService = sysVariablesService;
	}

	public SysVariables getSysVariables() {
		return sysVariables;
	}

	public void setSysVariables(SysVariables sysVariables) {
		this.sysVariables = sysVariables;
	}

}
